package com.define.commons.common.base;

import com.define.commons.common.context.FilterContextHandler;
import com.define.commons.common.dto.UserToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Controller基类
 * @Author xiewenlong
 * @Date 2018/11/9 15:03
 */
@Slf4j
public abstract class BaseController extends ExceptionHandlerController{

    /** built-in object start */
    @Autowired
    protected HttpSession session;
    @Autowired
    protected HttpServletRequest request;
    @Autowired
    protected HttpServletResponse response;
    /** built-in object end */

    /** built-in method start */
    /**
     * 获取当前用户认证信息
     */
    public UserToken getCurrentUserToken(){
        return FilterContextHandler.getUserToken();
    }

    /** built-in method end */


/*    @Autowired
    protected BaseDao<T, I> beanDao;
    @Autowired
    protected BaseService<T, I> beanService;*/

   /* @GetMapping("get/{id}")
    protected T get(@PathVariable("id") I id){
        Assert.isNull(id, "id is null!");
        return beanService.getById(id);
    }
    @GetMapping("list")
    protected List<T> list(T bean){
        Query query = Query.build(bean);
        return beanService.list(query);
    }
    @GetMapping("page")
    protected PageInfo<T> page(T bean, PageParam pageParam){
        Query query = Query.build(bean).page(pageParam.getPageIndex(), pageParam.getPageSize());
        return MapperUtil.query(beanDao, query);
    }
    @PostMapping("save")
    protected Object save(T bean){
        Assert.isNull(bean, "bean is null!");
        return beanService.save(bean);
    }
    @DeleteMapping("del/{id}")
    protected Object del(@PathVariable("id") I id){
        Assert.isNull(id, "id is null!");
        return beanService.deleteById(id);
    }
*/

}
